from dao.BaseDao import BaseDao

class UserDao(BaseDao):
    def insert(self, username, password):
        query = "INSERT INTO user (username, password) VALUES (%s, %s)"
        values = (username, password)
        return self.execute_sql(query, values)

    def update(self, user_id, username, password):
        query = "UPDATE user SET username = %s, password = %s WHERE id = %s"
        values = (username, password, user_id)
        return self.execute_sql(query, values)

    def delete(self, user_id):
        query = "DELETE FROM user WHERE id = %s"
        values = (user_id,)
        return self.execute_sql(query, values)

    def get_all_users(self):
        query = "SELECT * FROM user"
        return self.execute_query(query)

    def get_user_by_id(self, user_id):
        query = "SELECT * FROM user WHERE id = %s"
        values = (user_id,)
        return self.execute_query(query, values)

    def get_user_by_username(self, username):
        query = "SELECT * FROM user WHERE username = %s"
        values = (username,)
        return self.execute_query(query, values)
